<?php
/* Category controller 
** thaodx@gmail.com
*/
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Gallery extends CI_Controller {
	// Layout used in this controller
    public $layout_view = 'layout/tattoos';

	public function index($cateCode = '', $page = 0, $lastId = 0)
	{
		//var_dump($cateCode);die;
		$this->load->model('Post_model', 'postModel');
		$this->load->model('Cate_model', 'cateModel');
		$cateInfo = $this->cateModel->getAllCate(7);		
		if(empty($cateInfo)) header('location:'.BASE_URL);

		$cate_act = $this->cateModel->getCateBySlug($cateCode);
		$cate_act = $cate_act[0];
		
		$this->load->helper(array('datetime', 'permalink', 'social', 'image'));		
		$latestPost = $this->postModel->getPostByCate($cate_act['category_id'], $page, CATE_LIMIT, $lastId);
	
		$additionTitle = '';
		if($page > 0){
		 	$additionTitle = ' - Trang '. ($page / CATE_LIMIT + 1);
		}
		$this->layout->title(SITE_TITLE . TITLE_SEPARATOR . $cateInfo['category_name'].' archive'.$additionTitle); // Set page title
		$this->layout->meta('<meta http-equiv="REFRESH" content="1800" />');
       	$data = array('latestPost' => $latestPost, 'page' => $page, 'cateInfo' => $cateInfo,'cate_act' => $cate_act['category_slug']);

       	$this->layout->view('gallery_index', $data);// Render view and layout
       	//echo 1;die;
	}
}